#include "relationframe.h"
#include "ui_Relations.h"

RelationFrame::RelationFrame(QWidget *parent) :
        QFrame(parent),
        ui(new Ui::Frame)
{
    ui->setupUi(this);
}

RelationFrame::~RelationFrame()
{

}

void RelationFrame::on_pushButton_addRelation_clicked()
{
    ui->listWidget_name->addItem("New Relation");
    QListWidgetItem *relation = ui->listWidget_name->item(ui->listWidget_name->count() - 1);
    relation->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);
    relation->setSelected(true);
    ui->pushButton_addField->setEnabled(true);
    ui->pushButton_deleteRelation->setEnabled(true);
}

void RelationFrame::on_pushButton_addField_clicked()
{
    ui->listWidget_fields->addItem("New Field");
    QListWidgetItem *field = ui->listWidget_fields->item(ui->listWidget_fields->count() - 1);
    field->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);
    field->setSelected(true);
}

void RelationFrame::renameRelation()
{
    QListWidgetItem *item = ui->listWidget_name->currentItem();
    item->type();
}
